package tts.controller.users;

import org.springframework.beans.factory.annotation.Autowired;

import tts.controller.RedirectAction;
import tts.dao.UsersHome;
import tts.model.Users;

public class Get extends RedirectAction{

	//fields
	private static final long serialVersionUID = 9032010002522511019L;
	@Autowired
	private UsersHome usersHome;
	private Users user;
	private String username;

	//get & set
	public Users getUser() {
		return user;
	}
	public void setUser(Users user) {
		this.user = user;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}

	public void get() {
		try {
			this.user=usersHome.findByUsername(username);
			this.getServletRequest().setAttribute("user", user);
		} catch (RuntimeException e) {
			addActionError(e.getMessage());
		}
	}
}